var util = require('../../../../utils/util')   //引入配置公共请求接口
import { foundApi } from '../../../../config/config'
const app = getApp()

Page({

  /**
   * 页面的初始数据
   */
  data: {
    footprintGuid: '', //足迹全局id
    src: ''
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    wx.setNavigationBarColor({
      frontColor: '#000000',
      backgroundColor: '#ffffff'
    })
    app.reqFun.requestJson('GET',foundApi.getRegisterData,'',(res)=>{
      if(res.data.success === 1) {
        let data = res.data.data
        let token = data.token
        // let baseUrl = 'https://crmcs.quanyou.com.cn/appweb/#'
        let baseUrl = 'https://qmpdev.quanyou.com.cn/top2-crm-register'
        // let baseUrl = 'https://crm.quanyou.com.cn/appweb/#' //正式版 储存服务器地址 发版路径
        let partnerData = ''
        let thirdSource = 'MallRegistration'
        if (options.v == '3') {
          console.log('v3')
          // baseUrl += '/order/sign-up-3?token='
          baseUrl += '/registerPage?token='
          partnerData = '&sharingPeopleName=' + data.partnerName + '&sharingPeoplePhone=' + data.partnerPhone
          thirdSource = 'MallOldTakeNew'
        } else if (options.v == '2') {
          console.log('v2')
          // baseUrl += '/order/sign-up-2?token='
          baseUrl += '/registerPage?token='
          partnerData = '&sharingPeopleName=' + data.partnerName + '&sharingPeoplePhone=' + data.partnerPhone
        } else {
          console.log('v')
          baseUrl += '/registerPage?token='
        }

        let addrCode =  wx.getStorageSync('addrCode')
        let webUrl = baseUrl + token + '&sourceSystem=' + thirdSource + '&provinceCode=' + addrCode.provinceCode + '&cityCode=' + addrCode.cityCode + '&districtCode=' + addrCode.districtCode + '&streetCode=' + addrCode.townCode
        webUrl = webUrl + partnerData
        console.log('webUrl', webUrl)
        this.setData({
          src: webUrl
        })
      }
    })
  },


  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {
    this.setData({
      footprintGuid: util.guid()
    })
    //保存访问足迹
    app.saveAccessFootprint(this.data.footprintGuid, 'crmSignUp', null)
  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {
    //保存退出足迹
    app.saveQuitFootprint(this.data.footprintGuid)
  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {
    //保存退出足迹
    app.saveQuitFootprint(this.data.footprintGuid)
  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  // onShareAppMessage: function () {

  // }
})
